package com.gitee.melin.bee.core.support;

import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author admin@gmail.com
 */
public class CustomSQLUtil {
    private static final Logger LOGGER = LoggerFactory.getLogger(CustomSQLUtil.class);

    private static final CustomSQLUtil _instance = new CustomSQLUtil();

    private AtomicBoolean init = new AtomicBoolean(false);

    private CustomSQL customSQL;

    private CustomSQLUtil() {
        try {
            if (init.compareAndSet(false, true)) {
                customSQL = CustomSQL.getInstance();
            }
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }

    public static String get(String id) {
        return _instance.customSQL.get(id);
    }

    public static String get(String id, Map<String, Object> models) {
        return _instance.customSQL.get(id, models);
    }
}
